<?php 

$hashtags = (!empty($_GET['h']))?$_GET['h'] : '';
if(empty($hashtags))
	die("empty");
$api_url = "http://search.twitter.com/search.json?q=".$hashtags."&rpp=5&include_entities=true&with_twitter_user_id=true&result_type=mixed";
$file_path = "data/user.json";

$file = fopen($file_path,"a");



$rta_json = file_get_contents($api_url);

/*
{"created_at":"Thu Nov 22 21:04:25 +0000 2012","id":271720815412776961,"id_str":"271720815412776961","text":"Apagamos la maquinola de producci\u00f3n masiva de wireframes. Hasta ma\u00f1ana.","source":"\u003ca href=\"http:\/\/www.tweetdeck.com\" rel=\"nofollow\"\u003eTweetDeck\u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":39820000,"id_str":"39820000","name":"Pedro F. Garc\u00eda","screen_name":"Jinglero","location":"Argentina","url":"http:\/\/www.jinglero.com.ar","description":"Despacio, que estoy apurado.\r\nRides!","protected":false,"followers_count":183,"friends_count":259,"listed_count":7,"created_at":"Wed May 13 19:58:55 +0000 2009","favourites_count":6,"utc_offset":-10800,"time_zone":"Buenos Aires","geo_enabled":true,"verified":false,"statuses_count":4398,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"FFA200","profile_background_image_url":"http:\/\/a0.twimg.com\/profile_background_images\/127591927\/twiteer.jpg","profile_background_image_url_https":"https:\/\/si0.twimg.com\/profile_background_images\/127591927\/twiteer.jpg","profile_background_tile":false,"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/1121716133\/ba2ecdfb4b4be7139fe982645123fd3a_normal.jpeg","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/1121716133\/ba2ecdfb4b4be7139fe982645123fd3a_normal.jpeg","profile_banner_url":"https:\/\/si0.twimg.com\/profile_banners\/39820000\/1349201184","profile_link_color":"FF8C00","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"383838","profile_text_color":"666666","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":0,"entities":{"hashtags":[],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false}
*/

echo $rta_json;




fwrite($file, $rta_json);
fclose($file);

?>